package com.huynhchihieu.service;

import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.huynhchihieu.dao.GenericDAO;

@Service
@Transactional
public class GenericServiceImpl<T> implements GenericService<T> {

	@Autowired
	GenericDAO<T> genericDAO;
	
	

	public T create(T t) {

		return genericDAO.create(t);
	}

	public T find(Class<T> type, Object id) {
		return genericDAO.find(type, id);
	}

	public T update(T t) {
		return genericDAO.update(t);
	}

	public void delete(Class<T> type, Object id) {
		genericDAO.delete(type, id);
	}

	public List findWithNamedQuery(String queryName) {
		return genericDAO.findWithNamedQuery(queryName);
	}

	public List findWithNamedQuery(String queryName, int resultLimit) {
		return genericDAO.findWithNamedQuery(queryName, resultLimit);
	}

	public List findWithNamedQuery(String namedQueryName, Map parameters) {
		return genericDAO.findWithNamedQuery(namedQueryName, parameters);
	}

	public List findWithNamedQuery(String namedQueryName, Map parameters, int resultLimit) {
		return genericDAO.findWithNamedQuery(namedQueryName, parameters, resultLimit);
	}

}
